﻿using Sustainalytics.BusinessResearchProductStates.Entities.ResearchState;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Abstractions;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Sustainalytics.ScreeningTool.Synchronization.Tests
{
    [Trait("Category", "ScreeningData")]
    public class ScreeningSyncStepIntegrationTests
    {
        private static readonly Dictionary<string, string> GaConnectionStrings = new Dictionary<string, string>
        {
            { "ClientPlatform",        "mongodb://localhost:27017/ClientPlatform"          },
            { "ClientDW",              "mongodb://localhost:27017/ClientDW_A"              },
            { "ClientUniverses",       "mongodb://localhost:27017/ClientUniverses_A"       },
            { "CompanyReportPDF",      "mongodb://localhost:27017/CompanyReportPDF_A"      },
            { "ControversyReportPDF",  "mongodb://localhost:27017/ControversyReportPDF_A"  },
            { "DWArchive",             "mongodb://localhost:27017/DWArchive_A"             },
            { "GovernanceDW",          "mongodb://localhost:27017/GovernanceDW_A"          },
            { "ProductInvolvementDW",  "mongodb://localhost:27017/ProductInvolvementDW_A"  },
            { "RiskRatingsResearchDW", "mongodb://localhost:27017/RiskRatingsResearchDW_A" },
            { "ScreeningDW",           "mongodb://localhost:27017/ScreeningDW_A"           },
        };

        private static readonly Dictionary<string, string> DsConnectionStrings = new Dictionary<string, string>
        {
            { "ClientDW",              "mongodb://localhost:27017/ClientDW_A"              },
            { "ClientPlatform",        "mongodb://localhost:27018/ClientPlatform"          },
            { "ClientUniverses",       "mongodb://localhost:27017/ClientUniverses_A"       },
            { "CompanySearchDW",       "mongodb://localhost:27017/CompanySearchDW_A"       },
            { "GovernanceDW",          "mongodb://localhost:27017/GovernanceDW_A"          },
            { "RiskRatingsResearchDW", "mongodb://localhost:27017/RiskRatingsResearchDW_A" },
            { "ProductInvolvementDW",  "mongodb://localhost:27017/ProductInvolvementDW_A"  },
            { "ScreeningDW",           "mongodb://localhost:27018/ScreeningDW_A"           },
        };

        private static readonly IConfigurationManager configurationManager
            = new ConfigurationManager(new NameValueCollection
            {
                { "TearSheetAccountName", "Scotia iTrade" },
            });

        public ScreeningSyncStepIntegrationTests(ITestOutputHelper output)
        {
            Log.Initialize(output.WriteLine);
        }

        [Fact]
        public async Task CreateScreeningDataForGaAsync()
        {
            await ScreeningSyncStep.CreateScreeningDataAsync(
                ClientFacingProduct.GA,
                GaConnectionStrings,
                configurationManager);
        }

        [Fact]
        public async Task CreateScreeningDataForDsAsync()
        {
            await ScreeningSyncStep.CreateScreeningDataAsync(
                ClientFacingProduct.DS,
                DsConnectionStrings,
                configurationManager);
        }

        [Fact]
        public async Task CreateScreeningDataForGaAndDsAsync()
        {
            await CreateScreeningDataForGaAsync();
            await CreateScreeningDataForDsAsync();
        }
    }
}
